package com.sunchen.asc.service.user.vo;

import com.sunchen.asc.service.user.dto.UserDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.List;

@Data
@ApiModel(value="userVo对象",description="用户对象userVo")
public class UserVo implements Serializable {

    private String id;

    @ApiModelProperty(value="姓名",name="name")
    @NotEmpty(message = "姓名不能为空")
    @Size(max=10,min=1,message = "姓名长度要在1-10之间")
    private String name;

    @ApiModelProperty(value="登录名",name="userName")
    @NotEmpty(message = "登录名不能为空")
    @Size(max=20,min=6,message = "登录名长度要在8-20之间")
    private String userName;

    @ApiModelProperty(value="电话号码",name="tel")
    @Pattern(regexp = "^[1][3,4,5,7,8][0-9]{9}$" , message = "电话号码有误")
    private String tel;

    @ApiModelProperty(value="性别",name="sex")
    @NotNull(message = "性别不能为空")
    private int sex;

    @ApiModelProperty(value="邮箱",name="email")
    @Email(message = "邮箱格式有误")
    private String email;

    private int status;

    @ApiModelProperty(value="描述",name="description")
    private String description;

    private String roleStr;

    private List<RoleVo> roleVos;

    public UserVo(){}

    public UserVo(UserDto userDto) {
        this.id = userDto.getId().toString();
        this.name = userDto.getName();
        this.userName = userDto.getUserName();
        this.tel = userDto.getTel();
        this.sex = userDto.getSex();
        this.email = userDto.getEmail();
        this.status = userDto.getStatus();
        this.description = userDto.getDescription();
    }
}
